package com.ruihu.api.module.business.task.controller;

import com.ruihu.admin.common.anno.NoValidPrivilege;
import com.ruihu.admin.common.anno.OperateLog;
import com.ruihu.admin.common.controller.BaseController;
import com.ruihu.admin.common.domain.ResponseDTO;
import com.ruihu.admin.constant.SwaggerTagConst;
import com.ruihu.admin.module.business.tasknode.domain.dto.DefectTypeQueryDTO;
import com.ruihu.admin.module.business.tasknode.domain.vo.DefectTypeVO;
import com.ruihu.admin.module.business.tasknode.service.DefectTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * [ 缺陷类型配置 ]
 *
 * @author Tony
 * @version 1.0
 * @company 瑞虎（南京）信息技术有限公司
 * @copyright (c)  瑞虎（南京）信息技术有限公司Inc. All rights reserved.
 * @date 2022-09-04 10:46:11
 * @since JDK1.8
 */
@RestController("defectTypeApiController")
@Api(tags = {SwaggerTagConst.Mobile.SUB_TASK_API})
@OperateLog
public class DefectTypeController extends BaseController {

    @Autowired
    private DefectTypeService defectTypeService;

    @ApiOperation(value = "根据环节ID查询缺陷类型配置",notes = "@author Tony")
    @PostMapping("/api/defectType/list")
    @NoValidPrivilege
    public ResponseDTO<List<DefectTypeVO>> queryByList(@RequestBody DefectTypeQueryDTO queryDTO) {
        return this.defectTypeService.queryByList(queryDTO);
    }

    @ApiOperation(value = "查询缺陷类配置列表并根据任务节点ID分组",notes = "@author Tony")
    @PostMapping("/api/defectType/groupList")
    @NoValidPrivilege
    public ResponseDTO<Map<Long, List<DefectTypeVO>>> queryListGroupByTaskNode() {
        DefectTypeQueryDTO queryDTO = new DefectTypeQueryDTO();
        return this.defectTypeService.queryListGroupByTaskNode(queryDTO);
    }
}
